home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-10-08 | 4.6 KB | 210 lines | [TEXT/MWII] |
- ( T.W.K's White Knight Calculator. 10/08/91 )
- ( My own small attempt at being clever. Written this past )
- ( week while I was extreemly bored. It is written entirely )
- ( in White Knightese, 'cept for ResEdit. )
- ( The actual Calculator window, resource ID = 9001, the )
- ( Help and About windows, resource ID's 9002, & 9003, are )
- ( contained within this file. If you are unfamiliar with )
- ( writing this type of procedure, you'll need ResEdit or )
- ( similiar utility,to open this file to see those resources. )
- ( If you find out how to work with non-integers,let me know. )
- ( I decided not to go with a keypad, which I started to )
- ( do, because this way, you don't need to "MOUSE" around )
- ( with a keypad on the screen, you need only a keyboard to )
- ( use this procedure, and it makes for alot less code this )
- ( way too. )
- ( You need to be in TTY mode for the Print-to-Screen to )
- ( work, so your current emulation is checked, then changed )
- ( to TTY, and then restored to the previous mode. The same )
- ( thing happends for your duplex setting. )
- ( * This is all free stuff, but if you are suddenly stricken )
- ( with gifted insight by all this, please give me a small )
- ( plug in your next freebe upload, and in the mean time, )
- ( I'll promise to work on my modesty. )
-
- ( Here we go; First we clear all the variables that WE use, )
- ( that may have been set by another procedure. )
- ERASE A$
- ERASE B$
- ERASE C$
- ERASE D$
- ERASE E$
-
- ( Find out what emulation and duplex is set, so we can put )
- ( them back later. This is straight from my upload #1987. )
- ( >>>> Ouch! <<<< I hurt my arm patting myself on my back. )
- GETGLOBAL F%,0
- GETGLOBAL G%,3
-
- ( Now set duplex to null to avoid sending the text out the )
- ( modem and emulation to TTY. )
- COMM -NULL
- TTY
-
- :START
-
- SHELL A%,9001
-
- (---------------- Quit button, #10, 'Pushed'? )
- TEST A% = 10
- IF YES JUMPTO RESTORE
-
- (---------------- About button, #11 'Pushed'? )
- TEST A% = 11
- IF YES JUMPTO ABOUT
-
- (---------------- Help button, #2, 'Pushed'? )
- TEST A% = 2
- IF YES JUMPTO HELP
- IF NO JUMPTO SKIP
-
- (---------------- Get the About box. )
- :ABOUT
- SHELL A%,9003
-
- TEST A% = 1
- ( IMPRESSED! )
- IF YES JUMPTO START
-
- TEST A% = 2
- ( Not impressed; do a bad Bill the cat impression & quit. )
- IF YES BELL
- TYPE Pthbbbb
- BELL
- TYPE Pthbbbb
- BELL
- TYPE Pthbbbb
- BELL
- TYPE Pthbbbb
- BELL
- TYPE Pthbbbb^M^M^M
- JUMPTO RESTORE
- (---------------- End About button. )
-
- (---------------- Get the Help box. )
- :HELP
- SHELL A%,9002
-
- TEST A% = 1
- IF YES JUMPTO START
- (---------------- End Help button. )
-
- :SKIP
-
- ( Save the value of A$ into E$ so display looks correct. )
- COPYINTO E$,A$
-
- ( string-$ / number-% )
- ( Translate the strings to numbers to do math function. )
- STRINGTONUM A$,A%
- STRINGTONUM C$,C%
-
- ( Now we have to figure out what operation to perform. )
- ( But first we have to convert +,-,*,/, into a NUMSTRING. )
- ( * is a decimal 42, + is 43, - is 45, and / is 47 )
- BYTEVAL B$,1,B%
-
- ( :MULT --- We don't actully need a label here, so it's commented out. )
- TEST B% = 42
- IF NO JUMPTO ADD
- MULTIPLY A%,C%
- JUMPTO PRINT
-
- :ADD
- TEST B% = 43
- IF NO JUMPTO SUBTR
- ADD A%,C%
- JUMPTO PRINT
-
- :SUBTR
- TEST B% = 45
- IF NO JUMPTO DIV
- SUBTRACT A%,C%
- JUMPTO PRINT
-
- :DIV
- TEST B% = 47
- IF NO JUMPTO ERROR
- DIVIDE A%,C%
- JUMPTO PRINT
-
- :ERROR
- BELL
- TYPE Error... You must select Add(+) Subtract(-) Multiply(*) or Divide(/)^M
- COPYINTO D$, Error!
- JUMPTO START
-
- :PRINT
- TYPE A$
- TYPE ^M
- TYPE B$
- TYPE C$
- TYPE ^M
- TYPE _____________^M
-
- ( Convert the answer to text and print. )
- NUMTOSTRING A%,A$
- TYPE A$
- TYPE ^M ^M ^M
-
- ( Copy the answer to the bottom display, so the window looks OK. )
- COPYINTO D$,A$
- ( Now we correct the top display with the saved value in E$. )
- COPYINTO A$,E$
-
- JUMPTO START
-
- :RESTORE
- (-------> Start the terminal clean up. <-------)
- ( Check emulation... )
- TEST F% = 0
- IF NO JUMPTO ONE
- TTY
- JUMPTO DUPLEX
-
- :ONE
- TEST F% = 1
- IF NO JUMPTO TWO
- VT100
- JUMPTO DUPLEX
-
- :TWO
- TEST F% = 2
- IF NO JUMPTO THREE
- VT52
- JUMPTO DUPLEX
-
- :THREE
- ( TEST F% = 3 since this is the last choice,
- ( IF NO JUMPTO FOUR then VT102 must have been set,
- VT102
- ( JUMPTO DUPLEX so we don't test F% for it.
-
-
- :DUPLEX
- ( Now we have to restore the original duplex setting. )
- ( If G% was 0:FULL or 1:HALF or 2:ECHO or 3:NULL. )
- TEST G% = 0
- IF NO JUMPTO HALF
- COMM -FULL
- END
-
- :HALF
- TEST G% = 1
- IF NO JUMPTO ECHO
- COMM -HALF
- END
-
- :ECHO
- TEST G% = 2
- IF NO JUMPTO NULL
- COMM -ECHO
- END
-
- :NULL
- (No TEST or JUMPTO since this is the last choice)
- COMM -NULL
-
- (-------> The end <-------)
- END
-